﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using HYSoft.Common;
using HYSoft.Model;
using HYSoft.DALFactory;
using HYSoft.IDAL;

namespace HYSoft.BLL
{
    /// <summary>
    /// usr2node
    /// </summary>
    public partial class usr2node
    {
        private readonly Iusr2node dal = DataAccess.Createusr2node();
        public usr2node()
        { }
        #region  BasicMethod
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int index, int mac, string simno, string addr, string msgno, int areano, int adminno, int intvalue1, int intvalue2, int intvalue3, string charvalue1, string charvalue2, string charvalue3, string wendu, string dianchi, string gongdian, string dianliang, string chuanganqi, string jingbao, string tux, int value0, int rate0, int value1, int rate1, int value2, int rate2, int value3, int rate3, int value4, int rate4, int value5, int rate5, int user_index, string name, string mobile)
        {
            return dal.Exists(index, mac, simno, addr, msgno, areano, adminno, intvalue1, intvalue2, intvalue3, charvalue1, charvalue2, charvalue3, wendu, dianchi, gongdian, dianliang, chuanganqi, jingbao, tux, value0, rate0, value1, rate1, value2, rate2, value3, rate3, value4, rate4, value5, rate5, user_index, name, mobile);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(HYSoft.Model.usr2node model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(HYSoft.Model.usr2node model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int index, int mac, string simno, string addr, string msgno, int areano, int adminno, int intvalue1, int intvalue2, int intvalue3, string charvalue1, string charvalue2, string charvalue3, string wendu, string dianchi, string gongdian, string dianliang, string chuanganqi, string jingbao, string tux, int value0, int rate0, int value1, int rate1, int value2, int rate2, int value3, int rate3, int value4, int rate4, int value5, int rate5, int user_index, string name, string mobile)
        {

            return dal.Delete(index, mac, simno, addr, msgno, areano, adminno, intvalue1, intvalue2, intvalue3, charvalue1, charvalue2, charvalue3, wendu, dianchi, gongdian, dianliang, chuanganqi, jingbao, tux, value0, rate0, value1, rate1, value2, rate2, value3, rate3, value4, rate4, value5, rate5, user_index, name, mobile);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public HYSoft.Model.usr2node GetModel(int index, int mac, string simno, string addr, string msgno, int areano, int adminno, int intvalue1, int intvalue2, int intvalue3, string charvalue1, string charvalue2, string charvalue3, string wendu, string dianchi, string gongdian, string dianliang, string chuanganqi, string jingbao, string tux, int value0, int rate0, int value1, int rate1, int value2, int rate2, int value3, int rate3, int value4, int rate4, int value5, int rate5, int user_index, string name, string mobile)
        {

            return dal.GetModel(index, mac, simno, addr, msgno, areano, adminno, intvalue1, intvalue2, intvalue3, charvalue1, charvalue2, charvalue3, wendu, dianchi, gongdian, dianliang, chuanganqi, jingbao, tux, value0, rate0, value1, rate1, value2, rate2, value3, rate3, value4, rate4, value5, rate5, user_index, name, mobile);
        }

        /// <summary>
        /// 得到一个对象实体，从缓存中
        /// </summary>
        public HYSoft.Model.usr2node GetModelByCache(int index, int mac, string simno, string addr, string msgno, int areano, int adminno, int intvalue1, int intvalue2, int intvalue3, string charvalue1, string charvalue2, string charvalue3, string wendu, string dianchi, string gongdian, string dianliang, string chuanganqi, string jingbao, string tux, int value0, int rate0, int value1, int rate1, int value2, int rate2, int value3, int rate3, int value4, int rate4, int value5, int rate5, int user_index, string name, string mobile)
        {

            string CacheKey = "usr2nodeModel-" + index + mac + simno + addr + msgno + areano + adminno + intvalue1 + intvalue2 + intvalue3 + charvalue1 + charvalue2 + charvalue3 + wendu + dianchi + gongdian + dianliang + chuanganqi + jingbao + tux + value0 + rate0 + value1 + rate1 + value2 + rate2 + value3 + rate3 + value4 + rate4 + value5 + rate5 + user_index + name + mobile;
            object objModel = HYSoft.Common.DataCache.GetCache(CacheKey);
            if (objModel == null)
            {
                try
                {
                    objModel = dal.GetModel(index, mac, simno, addr, msgno, areano, adminno, intvalue1, intvalue2, intvalue3, charvalue1, charvalue2, charvalue3, wendu, dianchi, gongdian, dianliang, chuanganqi, jingbao, tux, value0, rate0, value1, rate1, value2, rate2, value3, rate3, value4, rate4, value5, rate5, user_index, name, mobile);
                    if (objModel != null)
                    {
                        int ModelCache = HYSoft.Common.ConfigHelper.GetConfigInt("ModelCache");
                        HYSoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
                    }
                }
                catch { }
            }
            return (HYSoft.Model.usr2node)objModel;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<HYSoft.Model.usr2node> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<HYSoft.Model.usr2node> DataTableToList(DataTable dt)
        {
            List<HYSoft.Model.usr2node> modelList = new List<HYSoft.Model.usr2node>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                HYSoft.Model.usr2node model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            return dal.GetRecordCount(strWhere);
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  BasicMethod
        #region  ExtensionMethod

        #endregion  ExtensionMethod
    }
}